package com.atguigu.java;

public class HelloThread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
//            try {
//                sleep(10);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
            if (i%2 == 0) {
                System.out.println(Thread.currentThread().getName()+":"+Thread.currentThread().getPriority()+":"+i);
//                if (i%10==0) {
//                    yield();
//
//                }

            }

        }
        System.out.println(Thread.currentThread().isAlive());
    }


}
class ThreadModeTest {

    public static void main(String[] args) {
        HelloThread h1 = new HelloThread();
        h1.setName("线程一");
        h1.setPriority(Thread.MAX_PRIORITY);
        h1.start();
        Thread.currentThread().setName("主线程");
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        for (int i = 0; i < 100; i++) {
            if (i%2 != 0) {
                System.out.println(Thread.currentThread().getName()+":"+Thread.currentThread().getPriority()+":"+i);

            }
//            if (i == 20) {
//                try {
//                    h1.join();
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//
//            }

        }



    }
}